# coding: utf-8
from . import db, BaseModel

from .consulting import Consulting




class ConsultMessage(db.Model):
    __tablename__ = 'consult_message'

    auto_id = db.Column(db.BigInteger, primary_key=True, info='自增id')
    consult_id = db.Column(db.ForeignKey('consulting.consult_id'), index=True, info='咨询id')
    last_mes_id = db.Column(db.BigInteger, info='上一条消息id')
    content = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), server_default=db.FetchedValue(), info='消息内容')
    is_delete = db.Column(db.Integer, server_default=db.FetchedValue(), info='是否已删除')
    create_time = db.Column(db.DateTime, server_default=db.FetchedValue(), info='创建时间')
    update_time = db.Column(db.DateTime, server_default=db.FetchedValue(), info='更新时间')

    consult = db.relationship('Consulting', primaryjoin='ConsultMessage.consult_id == Consulting.consult_id', backref='consult_messages')
